home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIBinaryOutputStream.idl < prev    next >
Text File  |  2006-05-08  |  4KB  |  120 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  * ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code, released
  16.  * March 31, 1998.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications Corporation.
  20.  * Portions created by the Initial Developer are Copyright (C) 1998-1999
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #include "nsIOutputStream.idl"
  40. #include "nsrootidl.idl"
  41.  
  42. /**
  43.  * This interface allows writing of primitive data types (integers,
  44.  * floating-point values, booleans, etc.) to a stream in a binary, untagged,
  45.  * fixed-endianness format.  This might be used, for example, to implement
  46.  * network protocols or to produce architecture-neutral binary disk files,
  47.  * i.e. ones that can be read and written by both big-endian and little-endian
  48.  * platforms.  Output is written in big-endian order (high-order byte first),
  49.  * as this is traditional network order.
  50.  *
  51.  * @See nsIBinaryInputStream
  52.  */
  53.  
  54. [scriptable, uuid(204ee610-8765-11d3-90cf-0040056a906e)]
  55. interface nsIBinaryOutputStream : nsIOutputStream {
  56.     void setOutputStream(in nsIOutputStream aOutputStream);
  57.     
  58.     void writeBoolean(in PRBool aBoolean);
  59.  
  60.     void write8(in PRUint8 aByte);
  61.     void write16(in PRUint16 a16);
  62.     void write32(in PRUint32 a32);
  63.     void write64(in PRUint64 a64);
  64.  
  65.     void writeFloat(in float aFloat);
  66.     void writeDouble(in double aDouble);
  67.  
  68.     /**
  69.      * Write a NUL-terminated 8-bit char* string to a binary stream.
  70.      */
  71.     void writeStringZ(in string aString);
  72.  
  73.     /**
  74.      * Write a NUL-terminated 16-bit PRUnichar* string to a binary stream.
  75.      */
  76.     void writeWStringZ(in wstring aString);
  77.  
  78.     /**
  79.      * Write a NUL-terminated UTF8-encoded string to a binary stream, produced
  80.      * from a NUL-terminated 16-bit PRUnichar* string argument.
  81.      */
  82.     void writeUtf8Z(in wstring aString);
  83.  
  84.     /**
  85.      * Write an opaque byte array to a binary stream.
  86.      */
  87.     void writeBytes([size_is(aLength)] in string aString, in PRUint32 aLength);
  88.  
  89.     /**
  90.      * Write an opaque byte array to a binary stream.
  91.      */
  92.     void writeByteArray([array, size_is(aLength)] in PRUint8 aBytes,
  93.                         in PRUint32 aLength);
  94.  
  95. };
  96.  
  97. %{C++
  98.  
  99. inline nsresult
  100. NS_WriteOptionalStringZ(nsIBinaryOutputStream* aStream, const char* aString)
  101. {
  102.     PRBool nonnull = (aString != nsnull);
  103.     nsresult rv = aStream->WriteBoolean(nonnull);
  104.     if (NS_SUCCEEDED(rv) && nonnull)
  105.         rv = aStream->WriteStringZ(aString);
  106.     return rv;
  107. }
  108.  
  109. inline nsresult
  110. NS_WriteOptionalWStringZ(nsIBinaryOutputStream* aStream, const PRUnichar* aString)
  111. {
  112.     PRBool nonnull = (aString != nsnull);
  113.     nsresult rv = aStream->WriteBoolean(nonnull);
  114.     if (NS_SUCCEEDED(rv) && nonnull)
  115.         rv = aStream->WriteWStringZ(aString);
  116.     return rv;
  117. }
  118.  
  119. %}
  120.